<?php
namespace app\home\controller;
use app\home\model\User;
use app\home\model\Film;
use app\home\model\Filmtype;
use app\home\model\Apply;
use app\home\model\Teacher;
use think\Request;
use think\Session;
class  Classroom extends Base
{
    public function index($tid="null"){
      $this->teacher_session($tid);
        $data = array(
            "videotype"=> Filmtype::where(['status'=>1])->order("sort","asc")->select(),
            "setting" => $this->getAllSetting(),
            "tid"=>$tid,
        );
        return view("index",$data);
    }
    // 视频列表
    public function videolist($videotype,$tid="null"){
      $this->teacher_session("tid");
      $data = [
        "setting" => $this->getAllSetting(),
        "videotype_name"=>Filmtype::where(["id"=>$videotype])->field("name")->find(),
        "video" =>Film::where(["status"=>1,"videotype"=>$videotype])->order("sort","asc")->paginate(15,true,['query'=>request()->param()]),
        "tid"=>$tid,
      ];
      return view("videolist",$data);
    }
    // 视频播放页面
    public function detail($id,$tid="null"){
      $this->teacher_session($tid);
      $data = [
        "setting"=>$this->getAllSetting(),
        "video" => Film::get($id),
        "videolist" => Film::order("id","desc")->limit(0,5)->select(),
        "qrcode" => $this->getSetting("teacher_qrcode"),
        "teacher" => Session::has("teacher_n") ? Session::get("teacher_n") : null,
        "tid"=>$tid,
      ];
      return view("detail",$data);
    }
}
